package org.imaginedays.androidall.component;

import org.imaginedays.androidall.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;

/**
 * 自定义view
 * 
 * @author imaginedays
 * 
 */
public class CutomView extends View {

	Paint mPaint;

	public CutomView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public CutomView(Context context, AttributeSet attrs) {
		super(context, attrs);
		mPaint = new Paint();
		TypedArray array = context.obtainStyledAttributes(attrs,
				R.styleable.custom_view);
		int textColor = array.getColor(R.styleable.custom_view_textColor,
				0XFF00FF00);
		float textSize = array.getDimension(R.styleable.custom_view_textSize,
				36);
		mPaint.setColor(textColor);
		mPaint.setTextSize(textSize);
		array.recycle();
	}

	public CutomView(Context context) {
		super(context);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		mPaint.setStyle(Style.FILL);
		canvas.drawRect(10,10,100,100, mPaint);
		mPaint.setColor(Color.BLUE);
		canvas.drawText("imaginedays", 10, 120, mPaint);
	}

}
